package com.more.offer.designpatterns.shareunit;

import java.awt.*;
import java.util.HashMap;
import java.util.Map;

/**
 * @author pinoc
 * @date 2021/10/25
 * @description
 */
public class TreeFactory {
	//缓存一些树（包含内置的状态）
	static Map<String, TreeType> treeTypes = new HashMap<>();

	public static TreeType getTreeType(String name, Color color, String otherTreeData) {
		TreeType result = treeTypes.get(name);
		if (result == null) {
			result = new TreeType(color, name, otherTreeData);
			treeTypes.put(name, result);
		}
		return result;
	}
}
